package studentinformationmanagementsystem.dao.impl;

import studentinformationmanagementsystem.dao.BaseDao;
import studentinformationmanagementsystem.dao.RequiredCourseDao;
import studentinformationmanagementsystem.entity.RequiredCourse;
import studentinformationmanagementsystem.entity.TakeACourse;
import studentinformationmanagementsystem.entity.TeachersSchedules;

import java.util.List;

/**
 * @author 苗庆
 * @version 1.0
 */
public class RequiredCourseDaoImpl extends BaseDao implements RequiredCourseDao {

    /**
     *
     * @param requiredCourse  必修课对象
     * @return
     */
    @Override
    public int insert(RequiredCourse requiredCourse) {
        String sql = "INSERT INTO `t_requiredcourse` (`studid`, `teachersschedulesid` ,achievement,`IsDelete`) VALUES (?, ? ,?,?)";
        return super.update(sql,requiredCourse.getStudid(),requiredCourse.getTeachersschedulesid(),requiredCourse.getAchievement(),requiredCourse.getIsDelete());
    }


    /**
     * 根据教师任课表id查询必修课信息
     * @param requiredCourse
     * @return
     */
    @Override
    public List<RequiredCourse> queryByRequiredCourse(RequiredCourse requiredCourse) {
        String sql = "SELECT * FROM `t_requiredcourse` WHERE `teachersschedulesid` = ? AND `IsDelete`=0";
        return super.queryForList(RequiredCourse.class, sql,requiredCourse.getTeachersschedulesid());
    }


    /**
     * 根据必修课id删除必修课信息
     * @param requiredCourse
     * @return
     */
    @Override
    public int delete(RequiredCourse requiredCourse) {
        String sql = "DELETE FROM `t_requiredcourse` WHERE `requiredcourseid` = ? AND `IsDelete`=0";
        return super.update(sql,requiredCourse.getRequiredcourseid());
    }

    @Override
    public List<RequiredCourse> queryBystudid(RequiredCourse requiredCourse) {
        String sql = "SELECT * FROM `t_requiredcourse` WHERE `studid` = ? AND `IsDelete`=0";
        return super.queryForList(RequiredCourse.class, sql, requiredCourse.getStudid());
    }


}
